#include <amxmodx>
#include <amxmisc>
#include <sqlx>
#include <newband>


#define NB_INFO_LEN 		32
#define NB_NO_RESULT 		-2
#define NB_ERROR 		-1
#define NB_QUERY_OK 		1

#define NB_OPT_UNBIND_ALL 	"u"
#define NB_OPT_BIND_KILL 	"k"
#define NB_OPT_DISCONNECT 	"d"
#define NB_OPT_EXIT 		"e"
#define NB_OPT_BIND_EXIT 	"s"
#define NB_OPT_PRINT_INFO 	"p"
#define NB_OPT_SLAY_EACH_ROUND	"s"

#define NB_PRINT_PNAME		"n"
#define NB_PRINT_PIP		"i"
#define NB_PRINT_PSTEAM		"s"
#define NB_PRINT_BDATE		"d"
#define NB_PRINT_BID		"u"
#define NB_PRINT_BTIME		"t"
#define NB_PRINT_BREASON	"r"
#define NB_PRINT_BSERVER	"h"
#define NB_PRINT_WWW		"w"
#define NB_PRINT_ANAME		"a"
#define NB_PRINT_ASTEAM		"z"

#define PREFIX 			"NEW_AMX_BAN"
#define AMX_CBAN_USAGE 		"Uzycie: amx_cban <czas w minutach (0 - perm> <name/#userId> <powod> - banuje gracza"
#define AMX_CBANIP_USAGE	"Uzycie: amx_cbanip <czas w minutach (0 - perm> <IP> <powod> - banuje dane ip (uzywac gdy gracz sie rozlaczyl)"
#define AMX_CBANSTEAM_USAGE	"Uzycie: amx_cbansteam <czas w minutach (0 - perm> <Steam Id> <powod> - banuje dane steam id (uzywac gdy gracz sie rozlaczyl)"

#define AMX_CUNBAN_USAGE	"Uzycie: amx_cunban <banId> - odbanowuje dane id"
#define AMX_GETCBANS_USAGE	"Uzycie: amx_getcbans <name> [flagi] - wyswietla bany dla danego name"
#define AMX_GETCBANS_FLAGS	"flagi: n - Name gracza ^n i - IP gracza^n s - SteamId gracza^n d - Data bana^n u - BanId (domyslnie nie jest wyswietlane)^n t - Czas bana^n r - Powod^n h - Serwer na ktorym dostal bana^n w - Strona forum^n a - Admin Name^n z - Admin Steam"

#define AMX_CBAN_FLAG 		ADMIN_BAN
#define AMX_CBANIP_FLAG 	ADMIN_BAN
#define AMX_CBANSTEAM_FLAG 	ADMIN_BAN
#define AMX_CUNBAN_FLAG 	ADMIN_BAN
#define AMX_GETCBANS_FLAG 	ADMIN_BAN


stock createCbanTable(Handle:dbTuple, const tableName[]){
	new ErrNo
	new Error[NB_ERR_LEN]
	new result = 0
	new Handle:sql = SQL_Connect(dbTuple, ErrNo, Error, NB_ERR_LEN -1)
	if(sql == Empty_Handle){
		log_amx("Error in newbanc.inc(createCbanTable): %s",Error)
	} else {
		new Handle: query = SQL_PrepareQuery(sql, "CREATE TABLE IF NOT EXISTS `%s` (\
		`id` int(11) NOT NULL AUTO_INCREMENT,\
		`p_name` varchar(50),\
		`p_ip` varchar(30),\
		`p_steam` varchar(30),\
		`ban_date` datetime,\
		`ban_time` int(11),\
		`ban_reason` varchar(100),\
		`ban_server` varchar(100),\
		`a_name` varchar(50),\
		`a_steam` varchar(30),\
		`ban_removed` varchar(1),\
		`ub_a_name` varchar(50),\
		`ub_a_steam` varchar(30),\
		PRIMARY KEY (`id`))", tableName)
		
		if(!SQL_Execute(query)){
			SQL_QueryError(query, Error, NB_ERR_LEN -1)
			log_amx("Error in newbanc.inc(createCbanTable): %s",Error)
		} else {
			result = 1
		}
		SQL_FreeHandle(query)
		SQL_FreeHandle(sql)
	}
	return result
}


stock getCbanInfo(Handle:dbTuple, const banTable[], banId, pName[], pSteam[], pIp[], bReason[], bDate[], &bTime, aName[], aSteam[], ubaName[], ubaSteam[], bServer[], unbanAlso = 0){
	new ErrNo
	new Error[NB_ERR_LEN]
	new result = 0
	new Handle:sql = SQL_Connect(dbTuple, ErrNo, Error, NB_ERR_LEN -1)
	if(sql == Empty_Handle){
		log_amx("Error in newbanc.inc(getCbanInfo): %s",Error)
		result = NB_ERROR
	} else {
		new sQuery[NB_LONG_STR]
		copy(sQuery, NB_LONG_STR -1, "select * from `%s` where %s\
		(`ban_time` == 0 or (`ban_date` + INTERVAL `ban_time` MINUTE > sysdate()) AND \
		( `id` = %d OR `p_ip` = '%s' OR `p_steam` = '%s')")
		
		new unBanStr[32]
		if(!unbanAlso){
			copy(unBanStr, 31, "`ub_a_name` is null AND ")
		}
		new Handle: query = SQL_PrepareQuery(sql,sQuery, banTable, unBanStr, banId, pIp, pSteam)
		if(!SQL_Execute(query)){
			SQL_QueryError(query, Error, NB_ERR_LEN -1)
			log_amx("Error in newbanc.inc(getCbanInfo): %s",Error)
			result = NB_ERROR
		} else {
			if(!SQL_NumResults(query)){
				result = NB_NO_RESULT
			} else {
				new i_pName = SQL_FieldNameToNum(query, "p_name")
				new i_pSteam = SQL_FieldNameToNum(query, "p_steam")
				new i_pIp = SQL_FieldNameToNum(query, "p_ip")
				new i_aName = SQL_FieldNameToNum(query, "a_name")
				new i_aSteam = SQL_FieldNameToNum(query, "a_steam")
				new i_ubaName = SQL_FieldNameToNum(query, "ub_a_name")
				new i_ubaSteam = SQL_FieldNameToNum(query, "ub_a_steam")
				
				new i_banReason = SQL_FieldNameToNum(query, "ban_reason")
				new i_banDate = SQL_FieldNameToNum(query, "ban_date")
				new i_banTime = SQL_FieldNameToNum(query, "ban_time")
				new i_banServer = SQL_FieldNameToNum(query, "ban_server")
		
				if (SQL_MoreResults(query)) {
					SQL_ReadResult(query, i_pName, pName, NB_NAME_LEN - 1)
					SQL_ReadResult(query, i_pSteam, pSteam, NB_STEAM_LEN - 1)
					SQL_ReadResult(query, i_pIp, pIp, NB_IP_LEN - 1)
					SQL_ReadResult(query, i_aName, aName, NB_NAME_LEN - 1)
					SQL_ReadResult(query, i_aSteam, aSteam, NB_STEAM_LEN - 1)
					SQL_ReadResult(query, i_ubaName, ubaName, NB_NAME_LEN - 1)
					SQL_ReadResult(query, i_ubaSteam, ubaSteam, NB_STEAM_LEN - 1)
					SQL_ReadResult(query, i_banReason, bReason, NB_STR_LEN - 1)
					SQL_ReadResult(query, i_banServer, bServer, NB_STR_LEN - 1)
					SQL_ReadResult(query, i_banDate, bDate, NB_STR_LEN - 1)
					bTime = SQL_ReadResult(query, i_banTime)
					result = NB_QUERY_OK
					}
			}
		}
		SQL_FreeHandle(query)
		SQL_FreeHandle(sql)
	}
	return result
}





stock processBan(Handle:dbTuple, const banTable[], const banOptions[], id, banId){
	new result = NB_QUERY_OK
	if(id < 0){
		return result
	}
	//console_cmd(id, "clear")
	//console_print(id, "processBan banOptions:%s", banOptions)
	new pName[NB_NAME_LEN]
	new pSteam[NB_STEAM_LEN]
	new pIp[NB_IP_LEN]
	new bReason[NB_STR_LEN]
	new bDate[NB_DATE_LEN]
	new bTime
	new aName[NB_NAME_LEN]
	new aSteam[NB_STEAM_LEN]
	new ubaName[NB_NAME_LEN]
	new ubaSteam[NB_STEAM_LEN]
	new bServer[NB_STR_LEN]
	
	get_user_ip(id, pIp, NB_IP_LEN, 1)
	get_user_authid(id, pSteam, NB_STEAM_LEN)
	
	if (isValidSteam(pSteam) < 1){
		copy(pSteam, NB_STEAM_LEN - 1, "")
	}
	result = getCbanInfo(dbTuple, banTable, banId, pName, pSteam, pIp, bReason, bDate, bTime, aName, aSteam, ubaName, ubaSteam, bServer)
	if(result == NB_QUERY_OK){
		if(strfind(banOptions, NB_OPT_UNBIND_ALL)>=0){
			console_cmd(id, "unbind all")
		}
		
		if(strfind(banOptions, NB_OPT_BIND_KILL)>=0){
			console_cmd(id, "bind mouse1 kill")
			console_cmd(id, "bind r kill")
			console_cmd(id, "bind e kill")
			console_cmd(id, "bind space kill")
			console_cmd(id, "bind 1 kill")
			console_cmd(id, "bind 2 kill")
			console_cmd(id, "bind 3 kill")
			console_cmd(id, "bind 4 kill")
			console_cmd(id, "bind 5 kill")
			console_cmd(id, "bind esc kill")
			console_cmd(id, "bind ~ kill")
		}
		
		if(strfind(banOptions, NB_OPT_BIND_EXIT)>=0){
			console_cmd(id, "bind mouse1 exit")
			console_cmd(id, "bind r exit")
			console_cmd(id, "bind e exit")
			console_cmd(id, "bind space exit")
			console_cmd(id, "bind 1 exit")
			console_cmd(id, "bind 2 exit")
			console_cmd(id, "bind 3 exit")
			console_cmd(id, "bind 4 exit")
			console_cmd(id, "bind 5 exit")
			console_cmd(id, "bind esc exit")
			console_cmd(id, "bind ~ exit")
		}
		
		if(strfind(banOptions, NB_OPT_PRINT_INFO)>=0){
			new printOpt[16]
			get_cvar_string("nb_print_opt", printOpt, 15)
			console_cmd(id, "clear")
			console_cmd(id, "echo ==============================")
			
			if(strfind(printOpt, NB_PRINT_PNAME)>=0){
				console_cmd(id, "echo [%s] Name: %s", PREFIX, pName)
			}
			if(strfind(printOpt, NB_PRINT_PIP)>=0){
				console_cmd(id, "echo [%s] IP: %s", PREFIX, pIp)
			}
			if(strfind(printOpt, NB_PRINT_PSTEAM)>=0){
				console_cmd(id, "echo [%s] Steam: %s", PREFIX, pSteam)
			}
			if(strfind(printOpt, NB_PRINT_BDATE)>=0){
				console_cmd(id, "echo [%s] Data: %s", PREFIX, bDate)
			}
			if(strfind(printOpt, NB_PRINT_BTIME)>=0){
				if(bTime > 0) {
					console_cmd(id, "echo [%s] Czas: %d Minut", PREFIX, bTime)
				} else {
					console_cmd(id, "echo [%s] Czas: na zawsze", PREFIX)
				}
			}
			if(strfind(printOpt, NB_PRINT_BREASON)>=0){
				console_cmd(id, "echo [%s] Powod: %s", PREFIX, bReason)
			}
			if(strfind(printOpt, NB_PRINT_BID)>=0){
				console_cmd(id, "echo [%s] BanId: %d", PREFIX, banId)
			}
			if(strfind(printOpt, NB_PRINT_ANAME)>=0){
				console_cmd(id, "echo [%s] Zbanowany przez: %s", PREFIX, aName)
			}
			if(strfind(printOpt, NB_PRINT_ASTEAM)>=0){
				console_cmd(id, "echo [%s] Steam Admina: %s", PREFIX, aSteam)
			}
			if(strfind(printOpt, NB_PRINT_BSERVER)>=0){
				console_cmd(id, "echo [%s] Zbanowany na serwerze: %s", PREFIX, bServer)
			}
			console_cmd(id, "echo ==============================")
		}
	}
	return result
}

stock writeConfigs(id, Array:configs){
	new i
	new cfgNum = ArraySize(configs)
	new fileName[NB_STR_LEN]
	for(i=0;i<cfgNum;i++){
		ArrayGetString(configs, i, fileName, NB_STR_LEN - 1)
		console_cmd(id, "writecfg %s", fileName)
	}
}

stock addCBan(Handle:dbTuple, const banTable[], &banId, const pName[], const pSteam[], const pIp[], const bReason[], bTime, const aName[], const aSteam[], const bServer[]){
	new ErrNo
	new Error[NB_ERR_LEN]
	new result = 0
	new Handle:sql = SQL_Connect(dbTuple, ErrNo, Error, NB_ERR_LEN -1)
	banId = -1
	
	if(sql == Empty_Handle){
		log_amx("Error in newbanc.inc(addCBan): %s",Error)
		result = NB_ERROR
	} else {
		new Handle: query = SQL_PrepareQuery(sql, "insert into `%s`(\
			`p_name`,`p_steam`,`p_ip`, `ban_date`, `ban_time`, `ban_reason`, `ban_server`, `a_name`, `a_steam`)\
		values('%s',	'%s',	'%s',	sysdate(),	%d,		'%s',		'%s',	'%s',		'%s')",
		banTable, pName, pSteam, pIp, bTime, bReason, bServer, aName, aSteam)
		if(!SQL_Execute(query)){
			SQL_QueryError(query, Error, NB_ERR_LEN -1)
			log_amx("Error in newbanc.inc(addCBan): %s",Error)
			result = NB_ERROR
		} else {
			banId = SQL_GetInsertId(query)
			if(banId <= 0)
				result = NB_NO_RESULT
			else
				result = NB_QUERY_OK
		}
		SQL_FreeHandle(query)
		SQL_FreeHandle(sql)
	}
	return result
}

stock removeCBan(id, Handle:dbTuple, const banTable[], banId){
	new ErrNo
	new Error[NB_ERR_LEN]
	new result = 0
	new Handle:sql = SQL_Connect(dbTuple, ErrNo, Error, NB_ERR_LEN -1)
	banId = -1
	if(sql == Empty_Handle){
		log_amx("Error in newbanc.inc(removeCBan): %s",Error)
		result = NB_ERROR
	} else {
		new Handle: query 
		if(get_cvar_num("nb_delete_on_unban")){
			query = SQL_PrepareQuery(sql, "delete from `%s` \
				where `id` = %d",
			banTable, banId)
		} else {
			new aName[NB_NAME_LEN]
			new aSteam[NB_STEAM_LEN]
			get_user_name(id, aName, NB_NAME_LEN -1)
			get_user_authid(id, aSteam, NB_STEAM_LEN -1)
			
			query = SQL_PrepareQuery(sql, "update `%s` \
				set `ub_a_name` = '%s', `ub_a_steam` = '%s' \
				where `id` = %d",
			banTable, aName, aSteam, banId)
		}
		if(!SQL_Execute(query)){
			SQL_QueryError(query, Error, NB_ERR_LEN -1)
			log_amx("Error in newbanc.inc(removeCBan): %s",Error)
			result = NB_ERROR
		} else {
			if(SQL_NumResults(query)){
				result = NB_QUERY_OK
			}
			else {
				result = NB_NO_RESULT
			}
		}
		SQL_FreeHandle(query)
		SQL_FreeHandle(sql)
	}
	return result
}
stock printCbans(id, Handle:dbTuple, const banTable[],const name[], const flags[]){
	new ErrNo
	new Error[NB_ERR_LEN]
	new result = 0
	new Handle:sql = SQL_Connect(dbTuple, ErrNo, Error, NB_ERR_LEN -1)
	new line[NB_LONG_STR]
	new line2[NB_LONG_STR]
	new line3[NB_LONG_STR]
	
	new pName[NB_NAME_LEN]
	new pSteam[NB_STEAM_LEN]
	new pIp[NB_IP_LEN]
	new bReason[NB_STR_LEN]
	new bDate[NB_DATE_LEN]
	new bTime[16]
	new aName[NB_NAME_LEN]
	new aSteam[NB_STEAM_LEN]
	new bServer[NB_STR_LEN]
	new banId
	
	if(sql == Empty_Handle){
		log_amx("Error in newbanc.inc(printCbans): %s",Error)
		result = NB_ERROR
	} else {
		new Handle: query = SQL_PrepareQuery(sql,"select `id`, `p_name`, `p_ip`, `p_steam`,\
			`a_name`, `a_steam`, `ban_reason`, `ban_date`, `ban_time`, `ban_server`, `ub_a_name` \
			from `%s` where `ub_a_name` is null and `p_name` like '%s%%' \
			and (`ban_time` = 0 or (`ban_date` + INTERVAL `ban_time` MINUTE > sysdate()))", banTable, name)
		if(!SQL_Execute(query)){
			SQL_QueryError(query, Error, NB_ERR_LEN -1)
			log_amx("Error in newbanc.inc(printCbans): %s",Error)
			new q[512]
			SQL_GetQueryString(query, q, 511)
			log_amx("Query: %s", q)
			result = NB_ERROR
		} else {
			if(!SQL_NumResults(query)){
				result = NB_NO_RESULT
			} else {
				new banNo =1
				while(SQL_MoreResults(query)){
					new i_banId = SQL_FieldNameToNum(query, "id")
					new i_pName = SQL_FieldNameToNum(query, "p_name")
					new i_pSteam = SQL_FieldNameToNum(query, "p_steam")
					new i_pIp = SQL_FieldNameToNum(query, "p_ip")
					new i_aName = SQL_FieldNameToNum(query, "a_name")
					new i_aSteam = SQL_FieldNameToNum(query, "a_steam")
					new i_banReason = SQL_FieldNameToNum(query, "ban_reason")
					new i_banDate = SQL_FieldNameToNum(query, "ban_date")
					new i_banTime = SQL_FieldNameToNum(query, "ban_time")
					new i_banServer = SQL_FieldNameToNum(query, "ban_server")
					line[0] = 0
					line2[0] = 0
					line3[0] = 0
					
					SQL_ReadResult(query, i_pName, pName, NB_NAME_LEN - 1)
					
					format(line, NB_LONG_STR, "%d.  Name: %s", banNo, pName)
					banNo ++
					
					banId = SQL_ReadResult(query, i_banId)
					format(line, NB_LONG_STR, "%s,   ", line)
					format(line, NB_LONG_STR, "%sBanId: %d", line, banId)
					
					if(strfind(flags, NB_PRINT_PIP)>=0){
						SQL_ReadResult(query, i_pIp, pIp, NB_IP_LEN - 1)
						format(line, NB_LONG_STR, "%s,   ", line)
						format(line, NB_LONG_STR, "%sIP: %s", line, pIp)
					}
					
					if(strfind(flags, NB_PRINT_PSTEAM)>=0){
						SQL_ReadResult(query, i_pSteam, pSteam, NB_STEAM_LEN - 1)
						format(line, NB_LONG_STR, "%s,   ", line)
						format(line, NB_LONG_STR, "%sSteam: %s", line, pSteam)
					}
					if(strfind(flags, NB_PRINT_BREASON)>=0){
						SQL_ReadResult(query, i_banReason, bReason, NB_STR_LEN - 1)
						if(strlen(line3)>0)
							format(line3, NB_LONG_STR, "%s,   ", line3)
						format(line3, NB_LONG_STR, "%sPowod: %s",line3, bReason)
					}	
					if(strfind(flags, NB_PRINT_BDATE)>=0){
						SQL_ReadResult(query, i_banDate, bDate ,NB_STR_LEN - 1)
						if(strlen(line3)>0)
							format(line3, NB_LONG_STR, "%s,   ", line3)
						format(line3, NB_LONG_STR, "%sData: %s", line3, bDate)
					}
					
					if(strfind(flags, NB_PRINT_BTIME)>=0){
						SQL_ReadResult(query, i_banTime, bTime, 15)
						if(strlen(line3)>0)
							format(line3, NB_LONG_STR, "%s,   ", line3)
						if(str_to_num(bTime) >0)
							format(line3, NB_LONG_STR, "%sCzas: %s Minut", line3, bTime)
						else
							format(line3, NB_LONG_STR, "%sCzas: Na zawsze", line3)
					}
					
					if(strfind(flags, NB_PRINT_ANAME)>=0){
						SQL_ReadResult(query, i_aName, aName, NB_NAME_LEN - 1)
						if(strlen(line2)>0)
							format(line2, NB_LONG_STR, "%s,   ", line2)
						format(line2, NB_LONG_STR, "%sAdmin: %s", line2, aName)
					}
					if(strfind(flags, NB_PRINT_ASTEAM)>=0){
						SQL_ReadResult(query, i_aSteam, aSteam, NB_STEAM_LEN - 1)
						if(strlen(line2)>0)
							format(line2, NB_LONG_STR, "%s,   ", line2)
						format(line2, NB_LONG_STR, "%sSteam Admina: %s", line2, aSteam)
					}	
					if(strfind(flags, NB_PRINT_BSERVER)>=0){
						SQL_ReadResult(query, i_banServer, bServer, NB_STR_LEN - 1)
						if(strlen(line2)>0)
							format(line2, NB_LONG_STR, "%s,   ", line2)
						format(line2, NB_LONG_STR, "%sServer: %s", line2, bServer)
					}
					console_print(id, line)
					if(strlen(line2)>0)
						console_print(id, "   %s", line2)
					if(strlen(line3)>0)
						console_print(id, "   %s", line3)
					SQL_NextRow(query)
					
				}
				
			}
		}
		SQL_FreeHandle(query)
		SQL_FreeHandle(sql)
	}
	return result
}


fillConfigs(Array:configs){	
	if(get_cvar_num("nb_custom_cfg")){
		fillCfgFromFile(configs)
	} else {
		fillDefCfg(configs)
	}
}
fillDefCfg(Array:configs){
	ArrayPushString(configs, "konfig")
	ArrayPushString(configs, "usr")
	ArrayPushString(configs, "save/default")
	ArrayPushString(configs, "cstrike")
	ArrayPushString(configs, "srv")
	ArrayPushString(configs, "maps/default")
	ArrayPushString(configs, "addons/cs")
	ArrayPushString(configs, "hl")
	ArrayPushString(configs, "default")
	ArrayPushString(configs, "custom")	
}
fillCfgFromFile(Array:configs){
	new CfgDir[NB_STR_LEN]
	get_configsdir(CfgDir, NB_STR_LEN - 1)
	new cfgFile[NB_STR_LEN]
	format(cfgFile, NB_STR_LEN -1, "%s/newban_custom.ini")
	new filesCount
	fillArray(cfgFile, configs, "nb_cfg", 0, filesCount)
}
fillTimes(Array: bantimes, Array:bantimesStrings){
	if(get_cvar_num("nb_custom_times")){
		new CfgDir[NB_STR_LEN]
		get_configsdir(CfgDir, NB_STR_LEN - 1)
		new cfgFile[NB_STR_LEN]
		format(cfgFile, NB_STR_LEN -1, "%s/newban_custom.ini")
		fillTimesFromFile(cfgFile, bantimes, bantimesStrings)
	} else {
		fillDefTimes(bantimes, bantimesStrings)
	}
}
fillDefTimes(Array: bantimes, Array:bantimesStrings)
{
	ArrayPushString(bantimesStrings, "Na tydzien")	//tydzien
	ArrayPushCell(bantimes, 10080)	//tydzien
	
	ArrayPushString(bantimesStrings, "Na 1 dzien") 	//dzien
	ArrayPushCell(bantimes, 1440) 	//dzien
	
	ArrayPushString(bantimesStrings, "Na godzine")	//godzina
	ArrayPushCell(bantimes, 60)	//godzina
	
	ArrayPushString(bantimesStrings, "Na 15 minut")
	ArrayPushCell(bantimes, 15)
	
	ArrayPushString(bantimesStrings, "Na 5 minut")
	ArrayPushCell(bantimes, 5)
	
	ArrayPushString(bantimesStrings, "Na zawsze")	//perm
	ArrayPushCell(bantimes, 0)	//perm
	}
fillTimesFromFile(const cfgFile[], Array: bantimes, Array:bantimesStrings){
	new a
	new b
	fillArray(cfgFile, bantimes, "nb_ban_time",7,  a, 1)
	fillArray(cfgFile, bantimesStrings, "nb_ban_time_desc",7,  b)
}
fillReasons(Array:banreasons){
	if(get_cvar_num("nb_custom_reasons")){
		new CfgDir[NB_STR_LEN]
		get_configsdir(CfgDir, NB_STR_LEN - 1)
		new cfgFile[NB_STR_LEN]
		format(cfgFile, NB_STR_LEN -1, "%s/newban_custom.ini")
		fillReasonsFromFile(cfgFile, banreasons)
	} else {
		fillDefReasons(banreasons)
	}
}
fillDefReasons(Array:banreasons){
	ArrayPushString(banreasons, "Czitujesz")
	ArrayPushString(banreasons, "Lagujesz/Ogarnij ping")
	ArrayPushString(banreasons, "Niekulturalne zachowanie")
	ArrayPushString(banreasons, "Utrudniasz gre/lamiesz regulamin")
	ArrayPushString(banreasons, "Reklamujesz")
	ArrayPushString(banreasons, "Ogranicz mikro")	
}

fillReasonsFromFile(const cfgFile[], Array: banreasons){
	new itemsAdded
	fillArray(cfgFile, banreasons, "nb_ban_reason", 7, itemsAdded)
}
